// 分割符，简单时代临时
const specialStr = [" ","\t","\r","\n","$","=","+","-",
                    "*","/","[",".","]",">","<","{","}",
                    "'",'"']
/**
 * 对php原码进行词法分析
 */
class Scanner{
    /**
     * 
     * @param {string} source 
     */
    constructor(source){
        // 原代码
        this.source = source+" ";
        // 生成的数据
        this.dataList=[]
    }
    get charCount(){
        return this.source.length;
    }
    static MODE_KEYWORD=0;
    static MODE_STRING=1;
    static MODE_OPERATOR=2
    /**
     * 先把它拆成一个一个的
     */
    cut(){
        //匹配类型
        let emptyExp=new RegExp("\\s");
        let keyWordExp=new RegExp("^[_a-Z0-9]");
        // 顺序读完整个语句
        let line =0; //第几行
        let char =0; //本行第几个字符。
        let keyStart = 0;//关键字开始于整个文档的第几个字符？
        let point=0; // 指针
        let mode=0;
        // let inDoc?
        while(point<this.charCount){
            if (emptyExp.test(this.source[point])){
                let keyword = this.source.substring(keyStart, point);
                if(keyword!=""){
                    this.dataList.push(keyword);
                }
                keyStart= point+1;
            }
            point++;
        }
    }
}